package it.mauriziobasile.sincrodir.gui;

import it.mauriziobasile.sincrodir.logica.FileSystem;

import java.awt.Color;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JTextField;

public class DirTestoAscoltatoreTasti implements KeyListener {

    private FinestraPrincipale finestraRef;

    public DirTestoAscoltatoreTasti(FinestraPrincipale finestraRef) {
        this.finestraRef=finestraRef;
    }
    
    @Override
    public void keyPressed(KeyEvent e) {
        // TODO Auto-generated method stub
    }

    @Override
    public void keyReleased(KeyEvent e) {
        JTextField txtf = (JTextField)e.getSource();
        if (FileSystem.esisteDir(txtf.getText()))
            txtf.setBackground(Color.GREEN);
        else
            txtf.setBackground(Color.RED);
        finestraRef.abilitaSincGui(finestraRef.verificaDir());
    }

    @Override
    public void keyTyped(KeyEvent e) {
        // TODO Auto-generated method stub
    }
}
